﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace ZuggerWpf
{
   public static class Convert
    {
        public static JObject jObjectName;
        /// <summary>
        /// 严重程度
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Severity(string eWord)
        {
            string cword = string.Empty;
            //if (jObjectName == null || jObjectName["Severity"] == null || jObjectName["Severity"][eWord] == null || jObjectName["Severity"][eWord].ToString() == "")
            //{
            //    cword = eWord;
            //}
            //else
            //    cword =jObjectName["Severity"][eWord].ToString();
            switch (eWord.ToLower().Trim())
            {
                case "1":
                    cword = "致命";
                    break;
                case "2":
                    cword = "严重";
                    break;
                case "3":
                    cword = "中等";
                    break;
                case "4":
                    cword = "轻微";
                    break;
                default:
                    eWord.ToLower().Trim();
                    break;
            }
            return cword;
        }
        /// <summary>
        /// 优先级别
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Pri(string eWord)
        {
            string cword = string.Empty;
            //if (jObjectName == null || jObjectName["Pri"] == null || jObjectName["Pri"][eWord] == null || jObjectName["Pri"][eWord].ToString() == "")
            //{
            //    cword = eWord;
            //}
            //else
            //    cword = jObjectName["Pri"][eWord].ToString();
            switch (eWord.ToLower().Trim())
            {
                case "1":
                    cword = "紧急";
                    break;
                case "2":
                    cword = "高";
                    break;
                case "3":
                    cword = "中";
                    break;
                case "4":
                    cword = "低";
                    break;
                default:
                    eWord.ToLower().Trim();
                    break;
            }
            return cword;
        }
        /// <summary>
        /// BUG解决方案
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Resolution(string eWord)
        {
            string cword = string.Empty;
            //if (jObjectName == null || jObjectName["Resolution"] == null || jObjectName["Resolution"][eWord] == null || jObjectName["Resolution"][eWord].ToString() == "")
            //{
            //    cword = eWord;
            //}
            //else
            //    cword = jObjectName["Resolution"][eWord].ToString();
            switch (eWord.ToLower().Trim())
            {
                case "bydesign":
                    cword = "设计如此";
                    break;
                case "duplicate":
                    cword = "重复BUG";
                    break;
                case "external":
                    cword = "外部原因";
                    break;
                case "fixed":
                    cword = "已解决";
                    break;
                case "notrepro":
                    cword = "无法重现";
                    break;
                case "postponed":
                    cword = "延期处理";
                    break;
                case "willnotfix":
                    cword = "不予解决";
                    break;
                case "toshory":
                    cword = "转为需求";
                    break;
                default:
                    eWord.ToLower().Trim();
                    break;
            }
            return cword;
        }
        /// <summary>
        /// BUG是否确认
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Confirmed(string eWord)
        {
            string cword = string.Empty;
            //if (jObjectName == null || jObjectName["Confirmed"] == null || jObjectName["Confirmed"][eWord] == null || jObjectName["Confirmed"][eWord].ToString() == "")
            //{
            //    cword = eWord;
            //}
            //else
            //    cword = jObjectName["Confirmed"][eWord].ToString();
            switch (eWord.ToLower().Trim())
            {
                case "0":
                    cword = "未确认";
                    break;
                case "1":
                    cword = "已确认";
                    break;
                default:
                    eWord.ToLower().Trim();
                    break;
            }
            return cword;
        }

        /// <summary>
        /// 需求或任务状态
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Status(string eWord)
        {
            string cword = string.Empty;
            //if (jObjectName == null || jObjectName["Status"] == null || jObjectName["Status"][eWord] == null || jObjectName["Status"][eWord].ToString() == "")
            //{
            //    cword = eWord;
            //}
            //else
            //    cword = jObjectName["Status"][eWord].ToString();
            switch (eWord.ToLower().Trim())
            {
                case "wait":
                    cword = "未开始";
                    break;
                case "doing":
                    cword = "进行中";
                    break;
                case "done":
                    cword = "已完成";
                    break;
                case "pause":
                    cword = "已暂停";
                    break;
                case "cancel":
                    cword = "已取消";
                    break;
                case "closed":
                    cword = "已关闭"; 
                    break;
                case "suspended":
                    cword = "已挂起"; 
                    break;
                case "draft":
                    cword = "草稿";
                    break;
                case "active":
                    cword = "激活";
                    break;
                case "changed":
                    cword = "已变更";
                    break;
                default:
                    eWord.ToLower().Trim();
                    break;
            }
            return cword;
        }
        /// <summary>
        /// 任务类型
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Type(string eWord)
        {
            string cword = string.Empty;
            //if (jObjectName== null || jObjectName["Type"] == null || jObjectName["Type"][eWord] == null || jObjectName["Type"][eWord].ToString() == "")
            //{
            //    cword = eWord;
            //}
            //else
            //    cword = jObjectName["Type"][eWord].ToString();
            switch (eWord.ToLower().Trim())
            {
                case "design":
                    cword = "文档设计";
                    break;
                case "devel":
                    cword = "程序开发";
                    break;
                case "test":
                    cword = "测试";
                    break;
                case "discuss":
                    cword = "讨论";
                    break;
                case "study":
                    cword = "研究";
                    break;
                case "ui":
                    cword = "UI美术";
                    break;
                case "affair":
                    cword = "事务";
                    break;
                case "custom":
                    cword = "自定义";
                    break;
                case "cycle":
                    cword = "周期";
                    break;
                case "bug":
                    cword = "Bug";
                    break;
                case "task":
                    cword = "项目任务";
                    break;
                case "story":
                    cword = "项目需求";
                    break;
                default:
                    eWord.ToLower().Trim();
                    break;
            }
            return cword;
        }

        /// <summary>
        /// 需求阶段
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Stage(string eWord)
        {
            string cword = string.Empty;
            //if (jObjectName == null || jObjectName["Stage"] == null || jObjectName["Stage"][eWord] == null || jObjectName["Stage"][eWord].ToString() == "")
            //{
            //    cword = eWord;
            //}
            //else
            //    cword = jObjectName["Stage"][eWord].ToString();
            switch (eWord.ToLower().Trim())
            {
                case "wait":
                    cword = "未开始";
                    break;
                case "planned":
                    cword = "已计划";
                    break;
                case "projected":
                    cword = "已立项";
                    break;
                case "developing":
                    cword = "研发中";
                    break;
                case "developed":
                    cword = "研发完毕";
                    break;
                case "testing":
                    cword = "测试中";
                    break;
                case "tested":
                    cword = "测试完毕";
                    break;
                case "verified":
                    cword = "已验收";
                    break;
                case "released":
                    cword = "已发布";
                    break;
                default:
                    eWord.ToLower().Trim();
                    break;
            }
            return cword;
        }
        /// <summary>
        /// 用户名字转换
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string User(string eWord)
        {
            string cword = string.Empty;
            if (jObjectName == null || jObjectName["users"] == null || jObjectName["users"][eWord] == null || jObjectName["users"][eWord].ToString() == "")
            {
                cword = eWord;
            }
            else
                cword = jObjectName["users"][eWord].ToString();

            return cword;
        }
       static Dictionary<string, string> ProjectNameDict = new Dictionary<string, string>();
        /// <summary>
        /// 项目名字转换
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string ProjectName(string eWord)
        {
            
            string cword = string.Empty;
            if (jObjectName == null || jObjectName["projects"] == null || jObjectName["projects"][eWord] == null || jObjectName["projects"][eWord].ToString() == "")
            {
                if (ProjectNameDict.ContainsKey(eWord))
                    cword = ProjectNameDict[eWord];
                else
                    cword = eWord;
            }
            else
            {
                cword = jObjectName["projects"][eWord].ToString();

                if (ProjectNameDict.ContainsKey(eWord))
                    ProjectNameDict[eWord] = cword;
                else
                    ProjectNameDict.Add(eWord, cword);
                
            }

            return cword;
        }
        static Dictionary<string, string> ProductNameDict = new Dictionary<string, string>();
        /// <summary>
        /// 产品名字转换
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string ProductName(string eWord)
        {

            string cword = string.Empty;
            if (jObjectName == null || jObjectName["products"] == null || jObjectName["products"][eWord] == null || jObjectName["products"][eWord].ToString() == "")
            {
                if (ProductNameDict.ContainsKey(eWord))
                    cword = ProductNameDict[eWord];
                else
                    cword = eWord;
            }
            else
            {
                cword = jObjectName["products"][eWord].ToString();

                if (ProductNameDict.ContainsKey(eWord))
                    ProductNameDict[eWord] = cword;
                else
                    ProductNameDict.Add(eWord, cword);

            }

            return cword;
        }

        static Dictionary<string, string> BuildNameDict = new Dictionary<string, string>();
        /// <summary>
        /// 发布版本名字转换
        /// </summary>
        /// <param name="eWord"></param>
        /// <returns></returns>
        public static string Build(string eWord)
        {
            string cword = string.Empty;
            if (jObjectName == null || jObjectName["builds"] == null || jObjectName["builds"][eWord] == null || jObjectName["builds"][eWord].ToString() == "")
            {
                if (BuildNameDict.ContainsKey(eWord))
                    cword = BuildNameDict[eWord];
                else
                    cword = eWord;
            }
            else
            {
                cword = jObjectName["builds"][eWord].ToString();

                if (BuildNameDict.ContainsKey(eWord))
                    BuildNameDict[eWord] = cword;
                else
                    BuildNameDict.Add(eWord, cword);

            }
            return cword;
        }
    }

}
